<template>
  <div class="news-detail">
    <myheader titleName='新闻详情'></myheader>
    <div>
      <h1 class="news-title">{{newsDetail.title}}</h1>
      <p class="news-info">
        <span>{{newsDetail.add_time | fmtTime}}</span>
        <span>{{newsDetail.click}}次浏览</span>
        <span>分类：教学</span>
      </p>
    </div>
    <div class="news-content" v-html='newsDetail.content'></div>
    <comment :id='$route.params.id'></comment>
  </div>
</template>
<script>
import myheader from '@/components/myheader'
import comment from '@/components/comment'
import { getNewsDetail } from '@/api'
export default {
  components: {
    myheader,
    comment
  },
  data () {
    return {
      newsDetail: {}
    }
  },
  created () {
    this.initTable()
  },
  methods: {
    initTable () {
      getNewsDetail(this.$route.params.id)
        .then(res => {
          console.log(res)
          this.newsDetail = res.message[0]
        })
    }
  }
}
</script>
<style lang="scss" scoped>
  .news-detail {
    padding: 40px 0 0 0;
    .news-title {
      font-size: 14px;
      font-weight: bold;
    }
    .news-info {
      font-size: 12px;
      color: #26a2ff;
      display: flex;
      justify-content: space-between;
    }
    .news-content {
      font-size: 12px;
    }
  }
</style>
